package auser;

import com.db4o.ext.ExtObjectContainer;

public class PianoDeiContiCareTaker {
	private Db4oCareTaker db4ct = null;
	public PianoDeiContiCareTaker (ExtObjectContainer cont){
		db4ct = new Db4oCareTaker(cont);
	}

	public boolean isCopy(PianoDeiConti wpc){
		PianoDeiConti emptyProto =null;
		if(wpc.getLivello()==4){
			emptyProto = new PianoDeiConti((String)null,wpc.getL1(),wpc.getL2(),wpc.getL3(),wpc.getL4(),wpc.getTipo(),wpc.getCircolo());
		}else{
			emptyProto = new PianoDeiConti((String)null,wpc.getL1(),wpc.getL2(),wpc.getL3(),wpc.getL4(),wpc.getTipo(),(Circolo)null);
		}
		
		return db4ct.objectIsCopy(emptyProto,wpc);
	}
	
	public void set(PianoDeiConti object) throws Exception {
		if(isCopy(object)) throw new Exception("Voce del piano dei conti gia esistente");
		else db4ct.set(object);
	}
	
	
}
